Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@babel/helper-annotate-as-pure
Advanced tools
Helper function to annotate paths and nodes with #__PURE__ comment
The @babel/helper-annotate-as-pure npm package is a utility within the Babel ecosystem designed to annotate call expressions with a /*#__PURE__*/ comment. This comment hints to JavaScript bundlers and minifiers, such as Terser, that the function call is pure. A pure function call's result can be safely removed if its result is not used, enabling more efficient final bundles by removing unused code.
Annotating a call expression as pure
This feature allows developers to mark specific call expressions as pure, enabling potential removal during the minification process if the result of the call is unused. This is particularly useful for library authors who want to ensure their library's unused parts can be tree-shaken in consumer applications.
import * as t from '@babel/types';
import annotateAsPure from '@babel/helper-annotate-as-pure';
const callExpression = t.callExpression(t.identifier('myFunction'), []);
annotateAsPure(callExpression);
// The callExpression node is now annotated with a /*#__PURE__*/ comment.
Similar to @babel/helper-annotate-as-pure, this package provides a Babel plugin to automatically annotate call expressions and new expressions with /*#__PURE__*/ comments. The key difference is that it operates at the plugin level, automatically applying the annotations across your codebase, rather than requiring manual annotation of each call.
While not a direct alternative, uglifyjs-webpack-plugin interfaces with UglifyJS to minify JavaScript bundles in Webpack projects. It can take advantage of the pure annotations added by @babel/helper-annotate-as-pure to perform tree shaking and dead code elimination, showcasing how such annotations can be utilized in the minification process.
Helper function to annotate paths and nodes with #PURE comment
See our website @babel/helper-annotate-as-pure for more information.
Using npm:
npm install --save @babel/helper-annotate-as-pure
or using yarn:
yarn add @babel/helper-annotate-as-pure
v7.25.9 (2024-10-22)
babel-parser
, babel-template
, babel-types
syntacticPlaceholders
mode (@liuxingbaoyu)babel-helper-compilation-targets
, babel-preset-env
ClassAccessorProperty
to prevent the no-undef
rule (@victorenator)babel-parser
, babel-types
VISITOR_KEYS
etc. faster to access (@liuxingbaoyu)FAQs
Helper function to annotate paths and nodes with #__PURE__ comment
The npm package @babel/helper-annotate-as-pure receives a total of 6,865,249 weekly downloads. As such, @babel/helper-annotate-as-pure popularity was classified as popular.
We found that @babel/helper-annotate-as-pure demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.